package com.zjk.controller;

import com.zjk.PageResult;
import com.zjk.Result;
import com.zjk.ResultObject;
import com.zjk.dto.BrandDTO;
import com.zjk.pojo.Brand;
import com.zjk.service.BrandService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

/**
 * @author: gfk
 * @create: 2022/10/13
 * @Description:
 * @FileName: BrandContrller
 * @History:
 * @自定义内容：
 */
@RestController
@RequestMapping("product/brand")
public class BrandContrller {
    @Autowired
    BrandService brandService;


    @PostMapping("/list/{pageNum}/{pageSize}")
    public PageResult list(@RequestBody Map searchMap, @PathVariable Integer pageNum,
                           @PathVariable Integer pageSize){
        return brandService.list(searchMap,pageNum,pageSize);
    }
    @GetMapping("/lists")
    public ResultObject<M> lists(){
        List<Brand> lists = brandService.lists();
        return new ResultObject<M>(true,1,"差U型你成功",lists);
    }
    @PostMapping("/add")
    public Result add(@RequestBody Brand brand){
         brandService.add(brand);
         return Result.SUCCESS();
    }
     @PostMapping("/update")
        public Result update(@RequestBody Brand brand){
             brandService.update(brand);
             return Result.SUCCESS();
        }
        @GetMapping("/delete/{brandId}")
        public Result delete(@PathVariable Long brandId){
             brandService.delete(brandId);
             return Result.SUCCESS();
        }

        @GetMapping("selectBrandDTOList/{pageNo}/{pageSize}")
        public PageResult<BrandDTO> selectBrandDTOList(@PathVariable Integer pageNo,
                                                       @PathVariable Integer pageSize,
                                                       @RequestBody Map searchMap){
            return brandService.selectBrandDTOList(pageNo,pageSize,searchMap);
        }


}
